/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package be.vdab.web;

/**
 *
 * @author lok1105
 */
class VanTotPostcodeForm {
    private final static  int MIN_POSTCODE = 1000;
    private final static  int MAX_POSTCODE = 9999;
    
    private Integer vanpostcode;
    private Integer totpostcode;
    
    public VanTotPostcodeForm () {}
    
    public VanTotPostcodeForm (Integer vanpostcode, Integer totpostcode) {
        valideer(vanpostcode);
        this.vanpostcode = vanpostcode;
        valideer(totpostcode);
        this.totpostcode = totpostcode;
    }

    public Integer getVanpostcode() {
        return vanpostcode;
    }

    public void setVanpostcode(Integer vanpostcode) {
        valideer(vanpostcode);
        this.vanpostcode = vanpostcode;
    }

    public Integer getTotpostcode() {
        return totpostcode;
    }

    public void setTotpostcode(Integer totpostcode) {
        valideer(totpostcode);
        this.totpostcode = totpostcode;
    }
    
    public String toString () {
        return vanpostcode + " - " + totpostcode;
    }
    
    private void valideer (int postcode) {
        if (postcode < MIN_POSTCODE || postcode > MAX_POSTCODE)
            throw new IllegalArgumentException();
    }
    
    public boolean isValid() {
        if (vanpostcode == null || totpostcode == null){
            return false;}
        return vanpostcode <= totpostcode;
    }
        
}
